<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>
    	<spring:message code="head.clothGarment"></spring:message>-
    	<spring:message code="head.userCenter"></spring:message>-
    	<spring:message code="head.personalInformation"></spring:message>
    </title>
    <!--公共样式-->
    <link href="${pageContext.request.contextPath }/web/css/font/iconfont.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/web/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/NormalizeFile.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/public.css" />
    <!--列表页面私有样式-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/subpage/person.css" />
</head>
<body>
	<jsp:include page="../../web/main/head.jsp"></jsp:include>
    <!--用户中心 begin-->
    <div class="contenter mar-t40 font1 mt134">
        <div class="font1" >
            <div class="cate-title">
               <b> <spring:message code="xuanzeshouhuodizhi"></spring:message></b>
            </div>
            <div class="order-detail-content shouhuo">
            <c:forEach items="${addressdefault}" var="addressdefault">
                <div id="${addressdefault.aId}" class="${addressdefault.aDefault==1?'envelope-bj':'noenvelope'}  f-l">
                    <div class="bor1-t pad-b15">${addressdefault.aName}</div>
                      <div class="address-phone">
                       ${addressdefault.aAddressInfo}<br/>
                       ${addressdefault.aPhone}
                     </div>
                </div>
            </c:forEach>
              <div class="clr"></div>
                <a href="javascript:insertdizhi()" class="shouhuo-address"><spring:message code="tianjiashouhuodizhi"></spring:message></a>
            </div>
            <div class="cate-title">
               <b> <spring:message code="querenshangpinxinxi"></spring:message></b>
            </div>
            <div class="order-detail-content">
              
                <div class="order-wei">
                    <div class="order-top bor1 bor-t0 h50 line-h50 detail-or-top">
                        <span class="w35"><spring:message code="chanpin"></spring:message></span>
                        <span class="w15"><spring:message code="changdumi"></spring:message></span>
                        <span class="w15"><spring:message code="danjiayuan"></spring:message></span>
                        <span class="w15"><spring:message code="jine"></spring:message></span>
                        <span class="w15"><spring:message code="fenlei"></spring:message></span>
                    </div>
                    <div class="order-content-wei">
                        <div class="or-detail">
                            <ul>
                            <c:set  var="count" value="0"></c:set>
                             <c:forEach items="${list}" var="item">
                              <c:set var="count" value="${count+item.scTotalPrice }"></c:set>
                                <li>
                                    <div class="w35">
                                        <div class="or8">
                                        <c:choose>
										<c:when test="${item.scType!=3}">
						                <img src="${item.scPatternImg}" />
						                </c:when>
						                <c:when test="${item.scType==3}">
						                <img src="${pageContext.request.contextPath }/upload/${item.fabricColor}" />
						             </c:when>
						             <c:otherwise>
						               <img src="${pageContext.request.contextPath }/web/img/bl2.jpg" />
						             </c:otherwise>
						             </c:choose>
                                        </div>
                                        <div class="or7 ">
                                    <c:choose>
										<c:when test="${item.scType==0}">
										 <p class="zichang" style="line-height:48px;"><spring:message code="huaxing"></spring:message>：${item.scPatternNo} <br/>
										 ${item.scNo}
										</c:when>
										<c:when test="${item.scType==1}">
										 <p class="zichang" style="line-height:100px;"><spring:message code="huaxing"></spring:message>：${item.scPatternNo}
	                                            
										</c:when>
										<c:when test="${item.scType==2}">
										 <p class="zichang" style="line-height:35px;"><spring:message code="huaxing"></spring:message>：${item.scPatternNo}
	                                            <br/>
	                                               	 <spring:message code="mianliao"></spring:message>：${item.scFabricNo} <br/>
	                                               	 	 ${item.scNo}
										</c:when>
										<c:when test="${item.scType==3}">
										<p class="zichang" style="line-height:100px;">
	                                               	<spring:message code="mianliao"></spring:message>：${item.scFabricNo}
										</c:when>
									</c:choose> 
                                            </p>
                                        </div>
                                    </div>
                                    
                                    <div class="w15">
                                         ${item.scFabricSize}
                                    </div>
                                    <div class="w15">
                                    	 ￥${item.scPatternSinglePrice }
                                    </div>
                                    <div class="w15">
                                         ￥${item.scTotalPrice }
                                    </div>
                                    <div class="w15">
                                   <c:choose>
									<c:when test="${item.scType==0}">
									<spring:message code="member.myShoppingCart.printing"></spring:message>
									</c:when>
									<c:when test="${item.scType==1}">
									<spring:message code="member.myShoppingCart.buyout"></spring:message>
									</c:when>
									<c:when test="${item.scType==2}">
									<spring:message code="member.myShoppingCart.endProduct"></spring:message>
									</c:when>
									<c:when test="${item.scType==3}">
									<spring:message code="member.myShoppingCart.ml"></spring:message>
									</c:when>
									</c:choose> 
                                    </div>
                                </li>
                                </c:forEach>
                            </ul>
                        </div>
                    </div>
                </div>

                <p class="real-pay">
                   <spring:message code="gongji"></spring:message>${fn:length(list) }<spring:message code="jianshangpin"></spring:message>&nbsp;&nbsp;<spring:message code="hejibuhanyunfei"></spring:message>：￥${count}
                </p>
                
                <div class="cate-title">
                   <b>  <spring:message code="kaijufapiao"></spring:message></b>
                </div>
                <div class="order-detail-content fapiao">
                    <div class="invoice">
                        <input type="radio" name="fapiao" checked="checked" id="k1" /><label><spring:message code="bukaifapiao"></spring:message></label>
                    </div>
                    <div class="invoice">
                        <input type="radio" name="fapiao" id="k2" /><label><spring:message code="putongfapiao"></spring:message></label>&nbsp;&nbsp;|&nbsp;&nbsp;<spring:message code="fapiaotaitou"></spring:message>：<input type="text" class="taitou" disabled="true" maxlength="50"/>&nbsp;&nbsp;<spring:message code="fapiaoneirong"></spring:message>
                    </div>
                </div>
                <p>
                    <input type="button" class="btn-red f-r" onclick="jiesuan()"  value="<spring:message code='qujiesuan'></spring:message>" style="margin-left:20px;" />
                    <input type="button" class="btn-gray f-r" onclick="fanhui()" value="<spring:message code='fanhuigouwuche'></spring:message>" style="margin-left:20px;" />
                </p>

            </div>
        </div>

        <div class="clr"></div>
        <form id="mai"  target="_top"   action="${pageContext.request.contextPath }/web/orders/caraccount" method="post">
        <input type="hidden" name="oId" id="oId" value="${fn:join(oId,',')}">
        </form>
        <form id="jiesuan">
        <input type="hidden" name="oId" id="oId" value="${fn:join(oId,',')}" autocomplete="off">
        <input type="hidden" name="addId" id="addId" value="${address!=null?address.aId:''}" autocomplete="off">
        <input type="hidden" name="taitou" id="taitou" autocomplete="off">
        <input type="hidden" name="instate" id="instate"  autocomplete="off">
        </form>
    </div>
    <!--用户中心 end-->
    <jsp:include page="../../web/main/bottom.jsp"></jsp:include>
    <!--全局-->
    <script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/web/js/public.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/2.1/layer.js"></script>
    <!--ie789下placeholder不兼容-->
    <script type="text/javascript" src="${pageContext.request.contextPath }/web/js/placeholder.js"></script>
    <!--头部的以图搜图-->
    <%-- <script type="text/javascript" src="${pageContext.request.contextPath }/web/js/uppicFile.js"></script> --%>
    <script type="text/javascript">
    /*发票开具*/
	$("input[name=fapiao]").click(function(){
		$("input[name=fapiao]").attr("checked",false);
		if($(this).next().text() == '<spring:message code="bukaifapiao"></spring:message>'){
			$(this).attr("checked",true);
			$(".taitou").val("");
			$(".taitou").attr("disabled",true);
		}else{
			$(this).attr("checked",true);
			$(".taitou").attr("disabled",false);
		}
	});
	
	/*地址选择*/
	$(".shouhuo .f-l").click(function(){

		$("#addId").val($(this).attr("id"));
		$(".shouhuo .f-l").removeClass("envelope-bj").addClass("noenvelope");
		$(this).addClass("envelope-bj").removeClass("noenvelope");
	});
    
    
    function jiesuan(){
		if($(".fapiao .invoice input[name=fapiao]").eq(1).attr("checked") == "checked"){
			$("#taitou").val($(".taitou").val());
			$("#instate").val(1);
			if($("#taitou").val()==""){
				layer.msg("<spring:message code='qingtianxiefapiaotaitou'></spring:message>", {icon: 0,time: 1000}); 
				return;
			}
		}else{
			$("#taitou").val("");
			$("#instate").val("0");
		}
		if($("#addId").val()==""){
			layer.msg("<spring:message code='qingxuanzeshouhuodizhi'></spring:message>", {icon: 0,time: 1000}); 
			return;
		}
		 $.ajax({
			 url:'${pageContext.request.contextPath }/web/orders/ordergenerated',
			 async : false,
			 data: $("#jiesuan").serialize(),
			 type : "POST", 
			 success :function(result){
			 var status=result.msg.status;
			 var desc=result.msg.desc;
			 if(status == 0){
				layer.msg("<spring:message code='xiadanchenggong'></spring:message>", {icon: 1,time: 1000},function(){
					location.href="${pageContext.request.contextPath }/member/member/myOrder-3/index";
				}); 
				
			 }else if(status ==1){//失败有花型失效
			    	 layer.msg("<spring:message code='youhuaxingbeimaiduanxiadanshibai'></spring:message>", {icon: 0,time: 1000}); 
			    }
			 }
			 });
		
    	
    }
    function fanhui(){
    	location.href="${pageContext.request.contextPath }/member/member/shoppingCart-4/index";
    }
    function insertdizhi(){
    	 layer.open({
		      type: 2,
		      title: '<spring:message code="reciveAddress.addReceiptAddress"></spring:message>',
		      shadeClose: true,
		      shade: false,
		      maxmin: true, //开启最大化最小化按钮
		      area: ['900px', '500px'],
		      content: '${pageContext.request.contextPath }/web/address/insertReciveAddress'
		    });
    }
    </script>
</body>
</html>